from fastapi import Request
from app.utils import tokenDecode
from utils import DEBUG

def loginCheck(token: str, request: Request):
    DEBUG(token)
    data, newToken = tokenDecode(token)
    DEBUG(data)
    DEBUG(newToken)
    if data == None:
        DEBUG("check failed!")
        return False
    else:
        if newToken != None:
            request.scope["new-token"] = newToken
        request.scope["token_data"] = data
        return True